/**
 * @author wangxiaowei
 * 组织部发文列表
 */
var sort = null;
var grid = null;
function initzuzhibufawenlist(){
		 Ext.BLANK_IMAGE_URL=Ext.get('basePath').getValue()+"ajaxFramework/ext-2.1/resources/images/default/s.gif";

Ext.menu.RangeMenu.prototype.icons = {
	  gt: './ajaxFramework/ext-2.1/img/greater_then.png', 
	  lt: './ajaxFramework/ext-2.1/img/less_then.png',
	  eq: './ajaxFramework/ext-2.1/img/equals.png'
	};
Ext.grid.filter.StringFilter.prototype.icon = './ajaxFramework/ext-2.1/img/find.png';

var filters = new Ext.grid.GridFilters({
		 cleanParams: function(p) {  // 清除参数的方法，要保留PagingToolbar分页用的两个参数
		   //var regex = new RegExp("^" + this.paramPrefix + "\[[0-9]+\]");
		   for(var key in p) {
		      if( key != 'start' && key != 'limit' )
		   //if(regex.test(key)) {
		    delete p[key];
		            //}
		               }
          },
	     buildQuery: function(filters) {	
		  // filters 就是getFilterData返回的值, 代码中push入去的对象
		  var p = {};
		  for(var i=0, len=filters.length; i<len; i++) {
		      var f = filters[i];
		      
		      // 取得在GridFilters中定义的filters中的一个filter
		      var filter = this.getFilter( f.field );
		      // 取得传递到server的参数名称
		      var name = (filter.paramName ? filter.paramName : filter.dataIndex);
		      var value = (filter.paramValue ? filter.paramValue : f.data['value']);
		      
		      if( value != '' ) p[ name ] = value;
		  }
		  return p;
		   },	
		  filters:[
		 	{type: 'string',  dataIndex: 'laiwenjihuan'},
		 	{type: 'string',  dataIndex: 'laiwenzihao'},
		 	{type: 'string',  dataIndex: 'zhaiyao'}
]});

var colModel = new Ext.grid.ColumnModel([
		{header:'总收文号',dataIndex:'zongshouwenhao',sortable:true},
		{header:'收文日期',dataIndex:'shouwenriqi',sortable:true},
		{header:'来文号',dataIndex:'laiwenzihao'},
		{header:'来文单位',dataIndex:'laiwenjihuan'},
		{header:'摘要',dataIndex:'zhaiyao'},
		{header:'操作',dataIndex:'operate',menuDisabled : true}
	]);
	var url = Ext.get('url').getValue();
	sort = new Ext.data.JsonStore({
		url:url,
		fields:['laiwenzihao','laiwenjihuan','operate','state','zongshouwenhao','shouwenriqi','laiwenjihuan','zhaiyao'],
		root:'root',
		plugins: filters,
		totalProperty:'totalProperty'
	});
	var bbar = new Ext.PagingToolbar({
		pageSize:23,
		store:sort,
		displayInfo:true,
		emptyMsg:'没有记录'
	});
	var permission = Ext.get('permission').getValue();
	if(permission.indexOf(",309,") >=0){
		grid = new Ext.grid.GridPanel({
			title:'党委收文查询',
				cm:colModel,
				plugins: filters,
				tbar:[{
					 text: '登记',
		             iconCls: 'silk-add',
		              handler:function(){
		             	window.location.href=Ext.get('basePath').getValue()+'tjsinfo/tjsoa/dangweishouwen/dengjifrom.do';
		             }
				}],	
				renderTo:'topic-grid',
				store:sort,
				loadMask:true,
				autoHeight:true,
				bbar:bbar,
				viewConfig:{
					forceFit:true,
					getRowClass:function(record,rowIndex,p,ds){
						if(record.get('state') == '是')
						{
							
							return 'red-row';
						}
						else if(record.get('state') == '中止')
						{
							
							return 'yellow-row';
						}
					}
				}
		});
		
	}else{
		grid = new Ext.grid.GridPanel({
				title:'党委收文查询',
				cm:colModel,
				renderTo:'topic-grid',
				store:sort,
				plugins: filters,
				loadMask:true,
				autoHeight:true,
				bbar:bbar,
				viewConfig:{
					forceFit:true,
					getRowClass:function(record,rowIndex,p,ds){
						if(record.get('state') == '是')
						{
							
							return 'red-row';
						}
						else if(record.get('state') == '中止')
						{
							
							return 'yellow-row';
						}
					}
				}
		});
	}
	
	sort.load({params:{start:parseInt(Ext.get('dangweishoujingshourenliststart').getValue()), limit: 23}});	
	
}




	
	